const sms = require('yi-sms');
module.exports = {
  description: '发送验证码',
  handler(req,res,next){
    let doc = req.body;
    let mobile = doc.mobile;
    let authCode = '';
    for(let i = 0;i<6;i++){
      authCode+=Math.floor(Math.random()*10)
    }
    authCode = '123456';
    let msg = "您本次的验证码为:"+authCode+",5 分钟内有效,请及时使用."
    let tokenExpires = 5*60;//5分钟
    req.redis.setValueAndExpire("mobile:"+mobile,authCode,tokenExpires,(e,r1)=>{
      if(e) return callback(e);
      // sms(mobile,msg,(e,r)=>{
      //   return res.reply({code:0,msg:"验证码发送成功!"})
      // })

      return res.reply({code:0,msg:"模拟测试发送短信验证码成功(123456)"})
    });
  }
}
